package p2pcdnsim.network.example;

import p2pcdnsim.exception.PortAlreadyInUseException;
import p2pcdnsim.network.ApplicationProcess;
import p2pcdnsim.network.GenericAddress;
import p2pcdnsim.network.Socket;
import desmoj.core.simulator.Model;

public class ExampleClientProcess extends ApplicationProcess {

	public ExampleClientProcess(Model owner, String name) {
		super(owner, name);
	}

	@Override
	protected void run() {
		Socket socket = null;
		try {
			System.out.println("["+this.currentTime()+"] Client: creating a socket");
			socket = this.createSocket(new GenericAddress("AddressNode2"),80);
		} catch (PortAlreadyInUseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int timeout = 1000;
		//establish a connection
		socket.open(timeout);
		System.out.println("["+this.currentTime()+"] Client: connection established");
	}

}
